!macro customInstall
  WriteRegStr HKCR ".md" "" "MDNote.Markdown"
  WriteRegStr HKCR "MDNote.Markdown" "" "Markdown Document"
  WriteRegStr HKCR "MDNote.Markdown\DefaultIcon" "" "$INSTDIR\MDNote.exe,0"
  WriteRegStr HKCR "MDNote.Markdown\shell\open\command" "" '"$INSTDIR\MDNote.exe" "%1"'
  
  ; 刷新 Windows 的文件关联缓存
  System::Call 'Shell32::SHChangeNotify(i 0x8000000, i 0, i 0, i 0)'
  
  ; 复制图标到安装目录
  CopyFiles "$INSTDIR\resources\app\build\icons\icon.ico" "$INSTDIR\resources\icon.ico"
  
  ; 设置开始菜单快捷方式图标
  CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}.lnk" "$INSTDIR\${PRODUCT_NAME}.exe" "" "$INSTDIR\resources\icon.ico"
  
  ; 设置桌面快捷方式图标
  CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\${PRODUCT_NAME}.exe" "" "$INSTDIR\resources\icon.ico"
!macroend

!macro customUninstall
  DeleteRegKey HKCR ".md"
  DeleteRegKey HKCR "MDNote.Markdown"
  
  ; 删除复制的图标
  Delete "$INSTDIR\resources\icon.ico"
  
  ; 刷新 Windows 的文件关联缓存
  System::Call 'Shell32::SHChangeNotify(i 0x8000000, i 0, i 0, i 0)'
!macroend 